# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=sensorfw
pkgver=0.12.6
pkgrel=2
pkgdesc="Sensorfw"
url="https://github.com/sailfishos/sensorfw"
arch="all"
license="LGPL-2.1-only"
depends="iio-sensor-proxy"
makedepends="
	doxygen
	elogind-dev
	eudev-dev
	qt5-qtbase-dev
	"
subpackages="$pkgname-dev $pkgname-doc $pkgname-openrc"
source="https://github.com/sailfishos/sensorfw/archive/$pkgver/sensorfw-$pkgver.tar.gz
	0001-Do-not-hide-stepcounter-by-default.patch
	0002-Add-heart-rate-monitor-sensor-with-hybris-adaptor.patch
	0003-Add-Wrist-gesture-sensor-via-libhybris-adaptor.patch
	0004-Fix-compilation-when-hybris-is-used.patch
	primaryuse.conf
	sensorfw.initd
	sensorfw.confd
	"
options="!check" # Broken, fails to find symbols

build() {
	qmake-qt5 \
		PREFIX=/usr
	make

	sed "s=@LIB@=lib=g" sensord-qt5.pc.in > sensord-qt5.pc
}

check() {
	make check
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	install -Dm644 -t "$pkgdir"/etc/sensorfw "$srcdir"/primaryuse.conf
	install -Dm755 "$srcdir"/sensorfw.initd "$pkgdir"/etc/init.d/sensorfw
	install -Dm644 "$srcdir"/sensorfw.confd "$pkgdir"/etc/conf.d/sensorfw

	mkdir -p "$pkgdir"/usr/share/dbus-1/system.d/
	mv "$pkgdir"/etc/dbus-1/system.d/* "$pkgdir"/usr/share/dbus-1/system.d/
}

sha512sums="
47ee9675ff0f573c001ca3d08934f01772a8bcf21486259edbd643ec586df4846afd8f7aceb76f7b0baf7b5445bf5ecd2927bbc0e068a917fa160e51d08773b2  sensorfw-0.12.6.tar.gz
0959dec01898ca1992967f9e8ad90ccba9a5123df3a5f67ed75666f930b4d14a858611ae6d72572bcdc0afa42ce8b6c8c1fabc1d9613fe69afd03fde50d1afad  0001-Do-not-hide-stepcounter-by-default.patch
aa3ece82d0383689928ae720a48b7ae470f0521b3398b35811668e691a0a4287cc900a43460a12a86c3185dd3440bcb283e35ab8c18858c0710bbad5d6c41058  0002-Add-heart-rate-monitor-sensor-with-hybris-adaptor.patch
b73478e7aa1ec0ebffcb32538932f025f172db25276266d9a6ccd227980562078313450484408f91634f8b92ad7d80c93aecffb038f5bb9595f901652bb97924  0003-Add-Wrist-gesture-sensor-via-libhybris-adaptor.patch
f3c33bd7a439bcccc10bfa4a030b06f020792e2d5f1edd5e7b9e96660a77c157a2a586f7870a62562e8cc1d3ecb9c111e9cd59ad9a6245ef258092e031349cdb  0004-Fix-compilation-when-hybris-is-used.patch
8e362f48fc5db58dc37d035f80f5ab0b09a20c82e6859e9662affdc192e2aa0bc7a259a9b0c63db330b3873d8b1f22af3f9193a0b7d79068354d1a788391376c  primaryuse.conf
17f5d578766b92022992fd5cd333d204a846d1111e7ef59234d7a907290e4cf9e9beb1cb0370b2c9c9982720e62effc5022e625469d9d64eb7613a8d6ef7f8c2  sensorfw.initd
b841282b96110ec59a7aa539db0737327b09549d55c78dc4b2c3b28b4a6ad1facf015b3175cb6d3a38f13e47aa6314ef3dc1514a4e60dd653a97409ec54ba706  sensorfw.confd
"
